package com.anxin.act.cmd;

import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.TaskEntity;

public class DeleteRuTaskCmd implements Command<Void> {
	private TaskEntity _currentTaskEntity;
	private String _deleteReason;

	public DeleteRuTaskCmd(TaskEntity currentTaskEntity) {
		_currentTaskEntity = currentTaskEntity;
	}

	public DeleteRuTaskCmd(TaskEntity currentTaskEntity, String deleteReason) {
		_currentTaskEntity = currentTaskEntity;
		_deleteReason = deleteReason;
	}

	// @Override
	public Void execute(CommandContext commandContext) {
		if (_currentTaskEntity != null) {

			Context.getCommandContext().getTaskEntityManager().
			deleteTask(_currentTaskEntity,null == _deleteReason ? TaskEntity.DELETE_REASON_DELETED: _deleteReason, false);
		}

		return null;
	}
}
